﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace IMIS_ERP.Web.Order_Info
{
    public partial class Report_Agent_Factory_Stay : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Pub_Useful.CheckRight.checkRight("ag_0|ag_1");
                Bind_GV();
            }
        }

        private void Bind_GV()
        {
            IMIS_ERP.BLL.Order_Info bll = new IMIS_ERP.BLL.Order_Info();
            DataSet ds = bll.GetStaySum_F(Session["aiProvince"].ToString(), "in(" + IMIS_ERP.BLL.Assistant.StrToQuotation(Session["aiArea"].ToString()) + ")");
            decimal sum1 = 0, sum2 = 0, sum3 = 0;
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                sum1 += Convert.ToDecimal(ds.Tables[0].Rows[i]["opOiIDSum"]);
                sum2 += Convert.ToDecimal(ds.Tables[0].Rows[i]["opNumSum"]);
                sum3 += Convert.ToDecimal(ds.Tables[0].Rows[i]["opAreaSum"]);
            }
            ds.Tables[0].Rows.Add("总计", sum1, sum2, sum3);
            GV.DataSource = ds.Tables[0];
            GV.DataBind();
        }

        /// <summary>响应GridView事件：创建数据行时
        /// 	<remark>2010-12-08 BY 河北大学信管团队</remark>
        /// </summary>
        protected void GV_RowCreated(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                //为数据行增加鼠标移动到行特性
                e.Row.Attributes.Add("onmouseover", "c=style.backgroundColor;this.style.backgroundColor='" + IMIS_ERP.BLL.Assistant.getColor1 + "'");
                //为数据行增加鼠标离开行特性
                e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
            }
        }
    }
}